var fs = require('fs');
var path = require('path');

function readFileList(dir, filesList = []) {
    const files = fs.readdirSync(dir);
    files.forEach((item, index) => {
        var fullPath = path.join(dir, item);
        const stat = fs.statSync(fullPath);
        if (stat.isDirectory()) {      
            readFileList(path.join(dir, item), filesList);  //递归读取文件
        } else {  
            if(fullPath.includes(fileType)&&!fullPath.includes(nothas)){              
            filesList.push(fullPath.replace(rootPath+'\\','').replace(fileType,'').replace('\\','/')); 
            }                    
        }        
    });
    return filesList;
}
 
var filesList = [];
var rootPath =''
var fileType = '.md'

var nothas ='README'
module.exports = function(name) {
    filesList=[]
    rootPath = path.join(__dirname,'../',name)
    readFileList(rootPath,filesList);
    return filesList
}